package com.guanyu.u2cache.exception;


import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;

/**
 * 自定义异常
 *
 * @author dandwj
 */
@Data
@Slf4j
public class BusinessException extends RuntimeException {

    private Object code;

    private String message;


    public BusinessException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BusinessException(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public BusinessException(HttpStatus httpStatus) {
        this.code = httpStatus.value();
        this.message = httpStatus.getReasonPhrase();
    }

    /**
     * bad request
     *
     * @param message
     */
    public BusinessException(String message) {
        this.message = message;
    }

    /**
     * bad request
     *
     * @param message
     */
    public BusinessException(String message, HttpStatus status) {
        this.code = status.value();
        this.message = message;
    }


}
